<template>
  <div class="order-container">
    <!-- 头部 -->
    <div class="header">
      <h1 class="title">我的订单</h1>
    </div>
    
    <!-- 订单列表 -->
  <div class="order-list">
    <!-- 订单1：待支付 -->
    <div class="order-item" @click="goToOrderDetail('2510122006450571550')">
      <div class="order-info">
        <div class="info-row">
          <span class="info-label">订单编号：</span>
          <span class="info-value">2510122006450571550</span>
        </div>
        <div class="info-row">
          <span class="info-label">订单时间：</span>
          <span class="info-value">2025-10-12 20:06:45</span>
        </div>
        <div class="info-row">
          <span class="info-label">认证公司：</span>
          <span class="info-value">北京星路程软件有限公司</span>
        </div>
        <div class="info-row">
          <span class="info-label">服务项目：</span>
          <span class="info-value">税务登记</span>
        </div>
        <div class="info-row">
          <span class="info-label">服务费用：</span>
          <span class="info-value price">359.00</span>
        </div>
        <div class="info-row">
          <span class="info-label">订单状态：</span>
          <span class="info-value status-pending">待支付</span>
        </div>
      </div>
      
      <div class="order-actions">
        <button class="cancel-btn">取消</button>
        <button class="pay-btn">去支付</button>
      </div>
    </div>
    
    <!-- 订单2：订单取消 -->
    <div class="order-item" @click="goToOrderDetail('2510121838040571563')">
      <div class="order-info">
        <div class="info-row">
          <span class="info-label">订单编号：</span>
          <span class="info-value">2510121838040571563</span>
        </div>
        <div class="info-row">
          <span class="info-label">订单时间：</span>
          <span class="info-value">2025-10-12 18:38:04</span>
        </div>
        <div class="info-row">
          <span class="info-label">认证公司：</span>
          <span class="info-value">北京星路程软件有限公司</span>
        </div>
        <div class="info-row">
          <span class="info-label">服务项目：</span>
          <span class="info-value">税务登记</span>
        </div>
        <div class="info-row">
          <span class="info-label">服务费用：</span>
          <span class="info-value price">359.00</span>
        </div>
        <div class="info-row">
          <span class="info-label">订单状态：</span>
          <span class="info-value status-canceled">订单取消</span>
        </div>
      </div>
    </div>
  </div>
    
    <!-- 底部按钮区域 -->
    <div class="bottom-buttons">
      <div class="bottom-button-item" @click="navigateTo('/pages/index/index')">
        <span class="button-icon">🏠</span>
        <span class="button-text">首页</span>
      </div>
      <div class="bottom-button-item active" @click="navigateTo('/pages/order/screenshot_order')">
        <span class="button-icon">📝</span>
        <span class="button-text">订单</span>
      </div>
      <div class="bottom-button-item" @click="navigateTo('/pages/user/index')">
        <span class="button-icon">👤</span>
        <span class="button-text">客服</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()

// 响应式数据
const orders = ref([])

// 页面导航
const navigateTo = (path) => {
  // 使用Vue Router进行路由跳转
  router.push(path)
}

// 跳转到订单详情
const goToOrderDetail = (orderId) => {
  // 在平板及以上设备上，订单详情应该显示在右侧
  // 这里通过路由参数传递订单ID
  router.push({ path: '/pages/order/order_detail', query: { orderId } })
}
</script>

<style scoped>
/* 页面容器 - 与首页完全一致，使用全局.app-container控制宽度 */
.order-container {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-color);
}

/* 头部样式 - 与首页完全一致 */
.header {
  padding: 16px;
  background-color: var(--white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

h1.title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin: 0;
}

/* 订单列表 */
.order-list {
  padding: 16px;
}

.order-item {
  background-color: var(--white);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.order-info {
  margin-bottom: 16px;
}

.info-row {
  display: flex;
  margin-bottom: 10px;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 13px;
  color: var(--text-light);
  width: 80px;
}

.info-value {
  font-size: 13px;
  color: var(--text-secondary);
  flex: 1;
}

.price {
  color: #ff4d4f;
  font-weight: 500;
}

.status-pending {
  color: #fa8c16;
}

.status-canceled {
  color: var(--text-light);
}

.status-completed {
  color: #52c41a;
}

/* 订单操作按钮 */
.order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.cancel-btn {
  padding: 6px 16px;
  background-color: #f5f5f5;
  color: var(--text-secondary);
  border-radius: 6px;
  font-size: 13px;
  border: none;
  cursor: pointer;
}

.pay-btn {
  padding: 6px 16px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  border: none;
  cursor: pointer;
}

/* 底部按钮区域 - 与首页完全一致 */
.bottom-buttons {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
  padding: 8px 0;
  z-index: 999;
}

.bottom-button-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.bottom-button-item.active {
  color: var(--primary-color);
}

.button-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.button-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.bottom-button-item.active .button-text {
  color: var(--primary-color);
}

/* 响应式设计 - 与首页完全一致 */
@media screen and (max-width: 320px) {
  .order-list {
    padding: 12px;
  }
  
  .order-item {
    padding: 12px;
  }
}

/* 移除页面级别的响应式宽度设置，完全依赖全局.app-container的宽度控制 */
@media screen and (min-width: 768px) {
  .bottom-buttons {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
  }
}
</style>